<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *物业费管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$data['name like']='%'.trim($_RQ['data']).'%';
		$data['uniacid']=$_SESSION['uniacid'];
		$zid=pdo_getcolumn('jy_smallquan_household',$data,'id');
		$params['zid']=$zid;
		$return['params']['zid']=$zid;
	}
	if(isset($_RQ['ispay'])){
		$params['ispay']=intval($_RQ['ispay']);
		$return['params']['ispay']=$_RQ['ispay'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','zid','mid','time','type','fee','xiangxi','status','ispay','paytime','createtime');
	$list=pdo_getslice('jy_smallquan_fee',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('y-m-d h:i',$item['createtime']);
			//$item['paytime']=date('y-m-d h:i',$item['paytime']);
			$item['zhuhu']=pdo_get('jy_smallquan_household',array('id'=>$item['zid']));
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'用户列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'zhuhu.name','title'=>'户主姓名','type'=>'string'),
			array('name'=>'zhuhu.mobile','title'=>'户主电话','type'=>'string'),
			array('name'=>'time','title'=>'月份','type'=>'string'),
			array('name'=>'fee','title'=>'费用','type'=>'string'),
			array('name'=>'ispay','title'=>'支付状态','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytime','title'=>'支付时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'用户姓名','type'=>'string'),
		)
	);
	$return['ispay']=array('待支付','已支付');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_smallquan_fee',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}